import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Date;
import java.util.*;
import java.io.*;
import java.sql.*;

public class SQLCall {
	public static int getNextSeq(Connection conn, String sequence)
	{
		int index = -1;
		try
		{
			String query = "SELECT " + sequence + ".nextval from dual"; 
			PreparedStatement pst = conn.prepareStatement(query);
			ResultSet rset = pst.executeQuery();
			rset.next();
			index = rset.getInt(1);
			pst.close();
		}
		catch(SQLException sqlError)
		{
			sqlError.printStackTrace();
		}
		return index;
	}
	
	public static ArrayList<Integer> getApeUsers(Connection conn) {
		ArrayList<Integer> userList = new ArrayList<Integer>();
		ResultSet user;
		try
		{
			PreparedStatement pst = conn.prepareStatement("SELECT user_id "+
			"FROM APE_USER");
			 user = pst.executeQuery();

			while(user.next())
			{
				userList.add(user.getInt("user_id"));
			}

			user.close();
		}
		catch(SQLException sqlError)
		{
			sqlError.printStackTrace();
		}

		return userList;
	}

}
